package com.example.liwushuo.adapter;

import java.util.List;

import com.example.liwushuo.bean.Candidate;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

public class TabAdapter extends FragmentPagerAdapter {

	private List<Fragment> list;
	private List<Candidate> Candidates;

	public TabAdapter(FragmentManager fm, List<Candidate> Candidates,
			List<Fragment> list) {
		super(fm);
		this.list = list;
		this.Candidates = Candidates;
	}

	@Override
	public Fragment getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public CharSequence getPageTitle(int position) {
		return Candidates != null && Candidates.size() > 0 ? Candidates.get(
				position).getName() : super.getPageTitle(position);
	}
}
